FROM python:3.9.16-slim

ARG SRC_DIR
ENV SRC_DIR ${SRC_DIR}
ARG SERVICE_PORT
ENV SERVICE_PORT ${SERVICE_PORT}
ARG SPACY_MODEL
ENV SPACY_MODEL ${SPACY_MODEL}
ARG TOKEN_ATTRIBUTES
ENV TOKEN_ATTRIBUTES ${TOKEN_ATTRIBUTES}
ARG ANNOTATE_BATCH_WITH_TOKENS_ONLY
ENV ANNOTATE_BATCH_WITH_TOKENS_ONLY ${ANNOTATE_BATCH_WITH_TOKENS_ONLY}

RUN mkdir /src

COPY $SRC_DIR/requirements.txt /src/requirements.txt

RUN pip install -r /src/requirements.txt && \
    python -m spacy download ${SPACY_MODEL}

COPY $SRC_DIR /src/
COPY ./common/ /src/common/

WORKDIR /src

CMD gunicorn --workers=2 server:app
